<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>范围库 (C++20)</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../common/favicon.ico">
<link rel="stylesheet" href="../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/ranges","wgTitle":"cpp/ranges","wgCurRevisionId":65199,"wgArticleId":11705,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"cpp/ranges","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_ranges skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading">范围库 <span class="t-mark-rev t-since-cxx20">(C++20)</span></h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../cpp.html" title="cpp">cpp</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="language.html" title="cpp/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="header.html" title="cpp/header">标准库头文件</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="freestanding.html" title="cpp/freestanding"> 自立与有宿主实现</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="named_req.html" title="cpp/named req">具名要求</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="utility.html#.E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81" title="cpp/utility">语言支持库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="concepts.html" title="cpp/concepts">概念库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="error.html" title="cpp/error">诊断库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="utility.html" title="cpp/utility">工具库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="string.html" title="cpp/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="https://zh.cppreference.com/w/cpp/container" title="cpp/container">容器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="iterator.html" title="cpp/iterator">迭代器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <strong class="selflink"> 范围库</strong> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="algorithm.html" title="cpp/algorithm">算法库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="numeric.html" title="cpp/numeric">数值库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="io.html" title="cpp/io">输入/输出库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="locale.html" title="cpp/locale">本地化库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="regex.html" title="cpp/regex">正则表达式库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="atomic.html" title="cpp/atomic">原子操作库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="thread.html" title="cpp/thread">线程支持库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="filesystem.html" title="cpp/filesystem">文件系统库</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="experimental.html" title="cpp/experimental">技术规范</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><strong class="selflink"> 范围库</strong><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> 范围访问</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/begin&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/begin（页面不存在）"><span class="t-lines"><span>begin</span><span>cbegin</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/end&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/end（页面不存在）"><span class="t-lines"><span>end</span><span>cend</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/rbegin&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/rbegin（页面不存在）"><span class="t-lines"><span>rbegin</span><span>crbegin</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/rend&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/rend（页面不存在）"><span class="t-lines"><span>rend</span><span>crend</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/size&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/size（页面不存在）"><span class="t-lines"><span>size</span><span>ssize</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/data&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/data（页面不存在）"><span class="t-lines"><span>data</span><span>cdata</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/empty&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/empty（页面不存在）"><span class="t-lines"><span>empty</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 范围原语</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/iterator_t.html" title="cpp/ranges/iterator t"><span class="t-lines"><span>iterator_t</span><span>sentinel_t</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/iterator_t.html" title="cpp/ranges/iterator t"><span class="t-lines"><span>range_size_t</span><span>range_difference_t</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/iterator_t.html" title="cpp/ranges/iterator t"><span class="t-lines"><span>range_value_t</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/iterator_t.html" title="cpp/ranges/iterator t"><span class="t-lines"><span>range_reference_t</span><span>range_rvalue_reference_t</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 悬垂迭代器处理</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/dangling.html" title="cpp/ranges/dangling"><span class="t-lines"><span>dangling</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/borrowed_iterator_t.html" title="cpp/ranges/borrowed iterator t"><span class="t-lines"><span>borrowed_iterator_t</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/borrowed_iterator_t.html" title="cpp/ranges/borrowed iterator t"><span class="t-lines"><span>borrowed_subrange_t</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 范围概念</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/range.html" title="cpp/ranges/range"><span class="t-lines"><span>range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/borrowed_range.html" title="cpp/ranges/borrowed range"><span class="t-lines"><span>borrowed_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/sized_range.html" title="cpp/ranges/sized range"><span class="t-lines"><span>sized_range</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/common_range.html" title="cpp/ranges/common range"><span class="t-lines"><span>common_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/view.html" title="cpp/ranges/view"><span class="t-lines"><span>view</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/viewable_range.html" title="cpp/ranges/viewable range"><span class="t-lines"><span>viewable_range</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/input_range.html" title="cpp/ranges/input range"><span class="t-lines"><span>input_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/output_range.html" title="cpp/ranges/output range"><span class="t-lines"><span>output_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/forward_range.html" title="cpp/ranges/forward range"><span class="t-lines"><span>forward_range</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/bidirectional_range.html" title="cpp/ranges/bidirectional range"><span class="t-lines"><span>bidirectional_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/random_access_range.html" title="cpp/ranges/random access range"><span class="t-lines"><span>random_access_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/contiguous_range.html" title="cpp/ranges/contiguous range"><span class="t-lines"><span>contiguous_range</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 视图</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/view_interface&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/view interface（页面不存在）"><span class="t-lines"><span>view_interface</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/subrange.html" title="cpp/ranges/subrange"><span class="t-lines"><span>subrange</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="ranges/semiregular_wrapper.html" title="cpp/ranges/semiregular wrapper">半正则包装</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 工厂</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/empty_view.html" title="cpp/ranges/empty view"><span class="t-lines"><span>empty_view</span><span>views::empty</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/single_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/single view（页面不存在）"><span class="t-lines"><span>single_view</span><span>views::single</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/iota_view.html" title="cpp/ranges/iota view"><span class="t-lines"><span>iota_view</span><span>views::iota</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/view_counted.html" title="cpp/ranges/view counted"><span class="t-lines"><span>views::counted</span></span></a></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 适配器</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/all_view.html" title="cpp/ranges/all view"><span class="t-lines"><span>views::all_t</span><span>views::all</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/join_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/join view（页面不存在）"><span class="t-lines"><span>join_view</span><span>views::join</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/take_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/take view（页面不存在）"><span class="t-lines"><span>take_view</span><span>views::take</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/basic_istream_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/basic istream view（页面不存在）"><span class="t-lines"><span>basic_istream_view</span><span>istream_view</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/ref_view.html" title="cpp/ranges/ref view"><span class="t-lines"><span>ref_view</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5">                              </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/split_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/split view（页面不存在）"><span class="t-lines"><span>split_view</span><span>views::split</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/take_while_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/take while view（页面不存在）"><span class="t-lines"><span>take_while_view</span><span>views::take_while</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/elements_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/elements view（页面不存在）"><span class="t-lines"><span>elements_view</span><span>views::elements</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/common_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/common view（页面不存在）"><span class="t-lines"><span>common_view</span><span>views::common</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/transform_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/transform view（页面不存在）"><span class="t-lines"><span>transform_view</span><span>views::transform</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/drop_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/drop view（页面不存在）"><span class="t-lines"><span>drop_view</span><span>views::drop</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/keys_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/keys view（页面不存在）"><span class="t-lines"><span>keys_view</span><span>views::keys</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/reverse_view.html" title="cpp/ranges/reverse view"><span class="t-lines"><span>reverse_view</span><span>views::reverse</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ranges/filter_view.html" title="cpp/ranges/filter view"><span class="t-lines"><span>filter_view</span><span>views::filter</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/drop_while_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/drop while view（页面不存在）"><span class="t-lines"><span>drop_while_view</span><span>views::drop_while</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/values_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/values view（页面不存在）"><span class="t-lines"><span>values_view</span><span>views::values</span></span></a></div></div></td></tr>
</table></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<p>范围库提供处理元素范围的组件，包括各种视图适配器。
</p>
<table class="t-dcl-begin"><tbody>
<tr class="t-dsc-header">
<td> <div>定义于头文件 <code><a href="header/ranges.html" title="cpp/header/ranges">&lt;ranges&gt;</a></code>
 </div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl">
<td class="t-dcl-nopad"> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">namespace</span> std <span class="br0">{</span><br>
<p>    <span class="kw1">namespace</span> views <span class="sy1">=</span> ranges<span class="sy4">::</span><span class="me2">views</span><span class="sy4">;</span><br>
</p>
<span class="br0">}</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>提供命名空间别名 <code>std::views</code> ，作为 <code>std::ranges::views</code> 的缩写。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;ranges&gt;</code> </div>
</td></tr>

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于命名空间 <code>std::ranges</code></div>
</td></tr>

<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E8.8C.83.E5.9B.B4.E8.AE.BF.E9.97.AE">  范围访问 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/begin&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/begin（页面不存在）"> <span class="t-lines"><span>begin</span><span>cbegin</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  返回指向范围起始的迭代器 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/end&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/end（页面不存在）"> <span class="t-lines"><span>end</span><span>cend</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  返回指向范围结尾的迭代器 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/rbegin&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/rbegin（页面不存在）"> <span class="t-lines"><span>rbegin</span><span>crbegin</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  返回指向范围的逆向迭代器 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/rend&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/rend（页面不存在）"> <span class="t-lines"><span>rend</span><span>crend</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  返回指向范围的逆向尾迭代器 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/size&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/size（页面不存在）"> <span class="t-lines"><span>size</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  获得能在常数时间内计算大小的范围的大小 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/empty&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/empty（页面不存在）"> <span class="t-lines"><span>empty</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  检查范围是否为空 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/data&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/data（页面不存在）"> <span class="t-lines"><span>data</span><span>cdata</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  获得指向连续范围的起始的指针 <br> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E8.8C.83.E5.9B.B4.E5.8E.9F.E8.AF.AD">  范围原语 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/iterator_t.html" title="cpp/ranges/iterator t"> <span class="t-lines"><span>iterator_t</span><span>sentinel_t</span><span>range_difference_t</span><span>range_size_t </span><span>range_value_t</span><span>range_reference_t</span><span>range_rvalue_reference_t</span></span></a></div></div>
</td>
<td>  获得范围的关联类型 <br> <span class="t-mark">(别名模板)</span> </td></tr>

<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.82.AC.E5.9E.82.E8.BF.AD.E4.BB.A3.E5.99.A8.E5.A4.84.E7.90.86">  悬垂迭代器处理 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/dangling.html" title="cpp/ranges/dangling"> <span class="t-lines"><span>dangling</span></span></a></div></div>
</td>
<td>  占位类型，指示不应返回迭代器或子范围，因为它可能悬垂 <br> <span class="t-mark">(类)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/borrowed_iterator_t.html" title="cpp/ranges/borrowed iterator t"> <span class="t-lines"><span>borrowed_iterator_t</span><span>borrowed_subrange_t</span></span></a></div></div>
</td>
<td>   获得塑造 <a href="ranges/borrowed_range.html" title="cpp/ranges/borrowed range"><tt>borrowed_range</tt></a> 的迭代器类型或子范围类型 <br> <span class="t-mark">(别名模板)</span> </td></tr>

<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E8.8C.83.E5.9B.B4.E6.A6.82.E5.BF.B5">  范围概念 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/range.html" title="cpp/ranges/range"> <span class="t-lines"><span>range</span></span></a></div></div>
</td>
<td>  指定类型为范围，即它同时提供 <code>begin</code> 迭代器和 <code>end</code> 哨位 <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/borrowed_range.html" title="cpp/ranges/borrowed range"> <span class="t-lines"><span>borrowed_range</span></span></a></div></div>
</td>
<td>   指定类型为 <a href="ranges/range.html" title="cpp/ranges/range"><tt>range</tt></a> 而且能安全返回从该类型表达式获得的迭代器而无悬垂之虞  <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/sized_range.html" title="cpp/ranges/sized range"> <span class="t-lines"><span>sized_range</span></span></a></div></div>
</td>
<td>  指定范围可在常数时间内知晓其大小 <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/view.html" title="cpp/ranges/view"> <span class="t-lines"><span>view</span></span></a></div></div>
</td>
<td>  指定范围为视图，即它拥有常数时间的复制/移动/赋值 <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/input_range.html" title="cpp/ranges/input range"> <span class="t-lines"><span>input_range</span></span></a></div></div>
</td>
<td>  指定范围的迭代器类型满足 <a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/iterator/input_iterator&amp;action=edit&amp;redlink=1" class="new" title="cpp/iterator/input iterator（页面不存在）"><tt>input_iterator</tt></a> <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/output_range.html" title="cpp/ranges/output range"> <span class="t-lines"><span>output_range</span></span></a></div></div>
</td>
<td>   指定范围的迭代器类型满足 <a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/iterator/output_iterator&amp;action=edit&amp;redlink=1" class="new" title="cpp/iterator/output iterator（页面不存在）"><tt>output_iterator</tt></a> <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/forward_range.html" title="cpp/ranges/forward range"> <span class="t-lines"><span>forward_range</span></span></a></div></div>
</td>
<td>   指定范围的迭代器类型满足 <a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/iterator/forward_iterator&amp;action=edit&amp;redlink=1" class="new" title="cpp/iterator/forward iterator（页面不存在）"><tt>forward_iterator</tt></a> <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/bidirectional_range.html" title="cpp/ranges/bidirectional range"> <span class="t-lines"><span>bidirectional_range</span></span></a></div></div>
</td>
<td>   指定范围的迭代器类型满足 <a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/iterator/bidirectional_iterator&amp;action=edit&amp;redlink=1" class="new" title="cpp/iterator/bidirectional iterator（页面不存在）"><tt>bidirectional_iterator</tt></a> <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/random_access_range.html" title="cpp/ranges/random access range"> <span class="t-lines"><span>random_access_range</span></span></a></div></div>
</td>
<td>   指定范围的迭代器类型满足 <a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/iterator/random_access_iterator&amp;action=edit&amp;redlink=1" class="new" title="cpp/iterator/random access iterator（页面不存在）"><tt>random_access_iterator</tt></a> <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/contiguous_range.html" title="cpp/ranges/contiguous range"> <span class="t-lines"><span>contiguous_range</span></span></a></div></div>
</td>
<td>   指定范围的迭代器类型满足 <a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/iterator/contiguous_iterator&amp;action=edit&amp;redlink=1" class="new" title="cpp/iterator/contiguous iterator（页面不存在）"><tt>contiguous_iterator</tt></a> <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/common_range.html" title="cpp/ranges/common range"> <span class="t-lines"><span>common_range</span></span></a></div></div>
</td>
<td>  指定范围拥有相同的迭代器和哨位类型 <br> <span class="t-mark">(概念)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/viewable_range.html" title="cpp/ranges/viewable range"> <span class="t-lines"><span>viewable_range</span></span></a></div></div>
</td>
<td>  指定针对 <a href="ranges/range.html" title="cpp/ranges/range"><tt>range</tt></a> 的要求，令其可安全转换为 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(概念)</span> </td></tr>

<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E8.A7.86.E5.9B.BE">  视图 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/view_interface&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/view interface（页面不存在）"> <span class="t-lines"><span>view_interface</span></span></a></div></div>
</td>
<td>  用于定义 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 的辅助类模板，使用奇特重现模板模式 <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/subrange.html" title="cpp/ranges/subrange"> <span class="t-lines"><span>subrange</span></span></a></div></div>
</td>
<td>  将迭代器/哨位对结合为一个 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E8.8C.83.E5.9B.B4.E5.B7.A5.E5.8E.82"> 范围工厂 </span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;ranges&gt;</code> </div>
</td></tr>

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于命名空间 <code>std::ranges</code></div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/empty_view.html" title="cpp/ranges/empty view"> <span class="t-lines"><span>empty_view</span><span>views::empty</span></span></a></div></div>
</td>
<td>  无元素的空 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(变量模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/single_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/single view（页面不存在）"> <span class="t-lines"><span>single_view</span><span>views::single</span></span></a></div></div>
</td>
<td>  含有具有指定值的单个元素的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/iota_view.html" title="cpp/ranges/iota view"> <span class="t-lines"><span>iota_view</span><span>views::iota</span></span></a></div></div>
</td>
<td>  由通过重复对某个初值自增所生成的序列组成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(定制点对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/view_counted.html" title="cpp/ranges/view counted"> <span class="t-lines"><span>views::counted</span></span></a></div></div>
</td>
<td>  从迭代器和计数创建子范围 <br> <span class="t-mark">(定制点对象)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E8.8C.83.E5.9B.B4.E9.80.82.E9.85.8D.E5.99.A8"> 范围适配器 </span></h3>
<p>范围适配器接受 <a href="ranges/viewable_range.html" title="cpp/ranges/viewable range"><tt>viewable_range</tt></a> 为其第一参数并返回一个 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 。
</p><p>若范围适配器仅接收一个参数，则它亦被称为使用管道运算符：若 <span class="t-c"><span class="mw-geshi cpp source-cpp">C</span></span> 是范围适配器对象且 <span class="t-c"><span class="mw-geshi cpp source-cpp">R</span></span> 为 <a href="ranges/viewable_range.html" title="cpp/ranges/viewable range"><tt>viewable_range</tt></a> ，则此二表达式等价：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1">C<span class="br0">(</span>R<span class="br0">)</span>
R <span class="sy3">|</span> C</pre></div></div>
<p>亦能连锁一元范围适配器以产生另一范围适配器：若 <span class="t-c"><span class="mw-geshi cpp source-cpp">C</span></span> 与 <span class="t-c"><span class="mw-geshi cpp source-cpp">D</span></span> 为范围适配器对象且 <span class="t-c"><span class="mw-geshi cpp source-cpp">R</span></span> 为 <a href="ranges/viewable_range.html" title="cpp/ranges/viewable range"><tt>viewable_range</tt></a> ，则 <span class="t-c"><span class="mw-geshi cpp source-cpp">C <span class="sy3">|</span> D</span></span> 亦为范围适配器对象，且此二表达式等价：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1">R <span class="sy3">|</span> C <span class="sy3">|</span> D   <span class="co1">// (R | C) | D</span>
R <span class="sy3">|</span> <span class="br0">(</span>C <span class="sy3">|</span> D<span class="br0">)</span></pre></div></div>
<p>若范围适配器接收多个参数，则这些形式等价：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1">adaptor<span class="br0">(</span>range, args...<span class="br0">)</span>
adaptor<span class="br0">(</span>args...<span class="br0">)</span><span class="br0">(</span>range<span class="br0">)</span>
range <span class="sy3">|</span> adaptor<span class="br0">(</span>args...<span class="br0">)</span></pre></div></div>
<p>此情况下， <span class="t-c"><span class="mw-geshi cpp source-cpp">adaptor<span class="br0">(</span>args...<span class="br0">)</span></span></span> 为一元范围适配器对象。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;ranges&gt;</code> </div>
</td></tr>

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于命名空间 <code>std::ranges</code></div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/all_view.html" title="cpp/ranges/all view"> <span class="t-lines"><span>views::all_t</span><span>views::all</span></span></a></div></div>
</td>
<td>  包含 <a href="ranges/range.html" title="cpp/ranges/range"><tt>range</tt></a> 的所有元素的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(别名模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/ref_view.html" title="cpp/ranges/ref view"> <span class="t-lines"><span>ref_view</span></span></a></div></div>
</td>
<td>  某个其他 <a href="ranges/range.html" title="cpp/ranges/range"><tt>range</tt></a> 的元素的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/filter_view.html" title="cpp/ranges/filter view"> <span class="t-lines"><span>filter_view</span><span>views::filter</span></span></a></div></div>
</td>
<td>  由 <a href="ranges/range.html" title="cpp/ranges/range"><tt>range</tt></a> 中满足某个谓词的元素构成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/transform_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/transform view（页面不存在）"> <span class="t-lines"><span>transform_view</span><span>views::transform</span></span></a></div></div>
</td>
<td>  对序列的每个元素应用某个变换函数的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/take_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/take view（页面不存在）"> <span class="t-lines"><span>take_view</span><span>views::take</span></span></a></div></div>
</td>
<td>  由另一 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 的前 N 个元素组成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/take_while_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/take while view（页面不存在）"> <span class="t-lines"><span>take_while_view</span><span>views::take_while</span></span></a></div></div>
</td>
<td>  由另一 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 的到首个谓词返回 <code>false</code> 为止的起始元素组成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a>  <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/drop_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/drop view（页面不存在）"> <span class="t-lines"><span>drop_view</span><span>views::drop</span></span></a></div></div>
</td>
<td>  由另一 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 跳过首 N 个元素组成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a>  <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/drop_while_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/drop while view（页面不存在）"> <span class="t-lines"><span>drop_while_view</span><span>views::drop_while</span></span></a></div></div>
</td>
<td>  由另一 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 跳过元素的起始序列，直至首个谓词返回 <code>false</code> 的元素组成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a>  <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/join_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/join view（页面不存在）"> <span class="t-lines"><span>join_view</span><span>views::join</span></span></a></div></div>
</td>
<td>  由拉平 <a href="ranges/range.html" title="cpp/ranges/range"><tt>range</tt></a> 的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 所获得的序列构成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/split_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/split view（页面不存在）"> <span class="t-lines"><span>split_view</span><span>views::split</span></span></a></div></div>
</td>
<td>  用某个分隔符切割另一 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 所获得的子范围的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a>  <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/common_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/common view（页面不存在）"> <span class="t-lines"><span>common_view</span><span>views::common</span></span></a></div></div>
</td>
<td>  转换 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 为 <a href="ranges/common_range.html" title="cpp/ranges/common range"><tt>common_range</tt></a>  <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ranges/reverse_view.html" title="cpp/ranges/reverse view"> <span class="t-lines"><span>reverse_view</span><span>views::reverse</span></span></a></div></div>
</td>
<td>  以逆序迭代另一双向视图上的元素的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/basic_istream_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/basic istream view（页面不存在）"> <span class="t-lines"><span>basic_istream_view</span><span>istream_view</span></span></a></div></div>
</td>
<td>  由在关联的输入流上相继应用 <code>operator&gt;&gt;</code> 获得的元素组成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> <br> <span class="t-mark">(类模板)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/elements_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/elements view（页面不存在）"> <span class="t-lines"><span>elements_view</span><span>views::elements</span></span></a></div></div>
</td>
<td>  选取仿 tuple 值组成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 和数值 N ，产生每个 tuple 的第 N 个元素的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a>  <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/keys_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/keys view（页面不存在）"> <span class="t-lines"><span>keys_view</span><span>views::keys</span></span></a></div></div>
</td>
<td>  选取仿 pair 值组成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 并产生每个 pair 的第一元素的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a>  <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges/values_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/values view（页面不存在）"> <span class="t-lines"><span>values_view</span><span>views::values</span></span></a></div></div>
</td>
<td>  选取仿 pair 值组成的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a> 并产生每个 pair 的第二元素的 <a href="ranges/view.html" title="cpp/ranges/view"><tt>view</tt></a>  <br> <span class="t-mark">(类模板)</span> <span class="t-mark">(范围适配器对象)</span> </td></tr>
</table>
<p>某些范围适配器用<a href="ranges/semiregular_wrapper.html" title="cpp/ranges/semiregular wrapper">半正则包装</a>包装其元素或函数对象。
</p>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">示例</span></h3>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">运行此代码</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;vector&gt;</span>
<span class="co2">#include &lt;ranges&gt;</span>
<span class="co2">#include &lt;iostream&gt;</span>
 
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    <a href="container/vector.html"><span class="kw1269">std::<span class="me2">vector</span></span></a><span class="sy1">&lt;</span><span class="kw4">int</span><span class="sy1">&gt;</span> ints<span class="br0">{</span><span class="nu0">0</span>,<span class="nu0">1</span>,<span class="nu0">2</span>,<span class="nu0">3</span>,<span class="nu0">4</span>,<span class="nu0">5</span><span class="br0">}</span><span class="sy4">;</span>
    <span class="kw4">auto</span> even <span class="sy1">=</span> <span class="br0">[</span><span class="br0">]</span><span class="br0">(</span><span class="kw4">int</span> i<span class="br0">)</span><span class="br0">{</span> <span class="kw1">return</span> <span class="nu0">0</span> <span class="sy1">==</span> i <span class="sy2">%</span> <span class="nu0">2</span><span class="sy4">;</span> <span class="br0">}</span><span class="sy4">;</span>
    <span class="kw4">auto</span> square <span class="sy1">=</span> <span class="br0">[</span><span class="br0">]</span><span class="br0">(</span><span class="kw4">int</span> i<span class="br0">)</span> <span class="br0">{</span> <span class="kw1">return</span> i <span class="sy2">*</span> i<span class="sy4">;</span> <span class="br0">}</span><span class="sy4">;</span>
 
    <span class="kw1">for</span> <span class="br0">(</span><span class="kw4">int</span> i <span class="sy4">:</span> ints <span class="sy3">|</span> std<span class="sy4">::</span><span class="me2">views</span><span class="sy4">::</span><span class="me2">filter</span><span class="br0">(</span>even<span class="br0">)</span> <span class="sy3">|</span> std<span class="sy4">::</span><span class="me2">views</span><span class="sy4">::</span><span class="me2">transform</span><span class="br0">(</span>square<span class="br0">)</span><span class="br0">)</span> <span class="br0">{</span>
        <a href="io/cout.html"><span class="kw1758">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> i <span class="sy1">&lt;&lt;</span> <span class="st0">' '</span><span class="sy4">;</span>
    <span class="br0">}</span>
<span class="br0">}</span></pre></div></div>
<p>输出：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">0 4 16</pre></div></div> 
</div>

<!-- 
NewPP limit report
Preprocessor visited node count: 25327/1000000
Preprocessor generated node count: 11873/1000000
Post‐expand include size: 314733/2097152 bytes
Template argument size: 57298/2097152 bytes
Highest expansion depth: 23/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:11705-0!*!0!!zh!*!zh!* and timestamp 20200310201243 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges&amp;oldid=65199">https://zh.cppreference.com/mwiki/index.php?title=cpp/ranges&amp;oldid=65199</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul><li><a href="https://zh.cppreference.com/w/cpp/ranges">Online version</a></li><li>Offline version retrieved 2020-03-14 18:00.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2020年3月4日 (星期三) 12:38。</li>
                                    <li id="footer-info-viewcount">此页面已被浏览过16,421次。</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 3.025 secs. -->
	</body>
<!-- Cached 20200310201243 -->
</html>